using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.Practices.CompositeUI;

using LibrErian.Common;
using LibrErian.Model;
using LibrErian.Interfaces.Services;


namespace LibrErian.Modules.BasicBook.Views.Library
{
    public class LibraryViewPresenter : Presenter<ILibraryView>
    {
        private Model.Library library;
        private ILibraryService libraryService;

        [ServiceDependency]
        public ILibraryService LibraryService
        {
            set
            {
                libraryService = value;
            }
        }

        [State]
        public Model.Library Library
        {
            set
            {
                library = value;
            }
        }

        public override void OnViewReady()
        {
            base.OnViewReady();

            View.SetLibrary(library);
        }

        public void OnSave()
        {
            libraryService.Save(library);
            this.CloseView();
        }

        public void OnCancel()
        {
            this.CloseView();
        }
    }

    public interface ILibraryView
    {
        void SetLibrary(Model.Library library);
    }
}
